<?php
class My_View_Helper_NombreUsuario extends Zend_View_Helper_Abstract
{

        private $nombreCache='usuarios';
        
        private $lifetime=7200;//2 horas
        private $automatic_serialization=true;
        private $cache_dir='tmp/';

       
        public function nombreUsuario($idZona)
        {
            
            //cache
            $frontendOptions = array('lifetime' => $this->lifetime,'automatic_serialization' => $this->automatic_serialization);
            $backendOptions = array('cache_dir' => $this->cache_dir);
            $cache = Zend_Cache::factory('Core','File',$frontendOptions,$backendOptions);
            
            
            if( ($result = $cache->load($this->nombreCache)) === false ) {
             
                // cache miss; connect to the database
             
                $db= Zend_Db_Table::getDefaultAdapter();
                $select = $db->select();
			    $select->from( array( $this->nombreCache), array( 'id', 'nombre' ) );
			    $result = $db->fetchPairs( $select );
             
                $cache->save($result, $this->nombreCache);
             
            } 
            
            return $result[$idZona];
  
        }   
}